package cn.fintecher.pangolin.service.manage.request;

import cn.fintecher.pangolin.common.enums.BaseStatus;
import cn.fintecher.pangolin.entity.mysql.QSysParam;
import com.querydsl.core.BooleanBuilder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.util.Objects;

/**
 * @Auther: xiaqun
 * @Description: 系统参数查询参数
 * @Date: 18:59 2019/8/14
 */

@Data
public class FindSysParamRequest {
    @ApiModelProperty(value = "参数名称")
    private String code;

    @ApiModelProperty(value = "是否启用")
    private BaseStatus status;

    public BooleanBuilder getBuilder() {
        BooleanBuilder builder = new BooleanBuilder();
        QSysParam qSysParam = QSysParam.sysParam;
        if (StringUtils.isNotBlank(this.code)) {
            builder.and(qSysParam.code.like("%" + StringUtils.trim(this.code) + "%"));
        }
        if (Objects.nonNull(status)) {
            builder.and(qSysParam.status.eq(this.status));
        }
        return builder;
    }
}
